package com.lanou.zhihu.web.controller;

import com.lanou.zhihu.entity.User;
import com.lanou.zhihu.service.FollowQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by QuChao on 2018/10/30.
 */
@Controller
@RequestMapping("/followQuestion")
public class FollowQuestionController {
    @Autowired
    private FollowQuestionService followQuestionService;

    @ResponseBody
    @RequestMapping("/question")
    public boolean followQuestion(Integer qid, HttpServletRequest request) {
        User user = (User) request.getSession().getAttribute("user");
        return followQuestionService.followQuestion(user, qid);
    }

    @ResponseBody
    @RequestMapping("/cancelQuestion")
    public boolean cancelQuestion(Integer qid, HttpServletRequest request) {
        User user = (User) request.getSession().getAttribute("user");
        return followQuestionService.cancelQuestion(user, qid);
    }

    @ResponseBody
    @RequestMapping("/getFollowInfo")
    public boolean getFollowInfo(Integer uid, Integer qid) {
        return followQuestionService.getFollowInfo(uid, qid);
    }
}
